package com.wangping.processors;

import java.util.ArrayList;
import java.util.List;

import com.wangping.StringUtils;

/*
 * After the first letter, any of the following letters are discarded: A, E, I, H, O, U, W, Y.
 */
public class DiscardedProcessor extends Processor4List implements IProcessor, IProcessor4List {
	//A, E, I, H, O, U, W, Y
	//public static final char[] discards = {'A','E','I','H','O','U','W','Y'};
	public static final String DISCARDS = "AEIHOUWY";
	public String process(String str) {
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 1; i<str.length(); i++) {
			char tempc = str.charAt(i);
			if(DISCARDS.indexOf(tempc) != -1){
				list.add(i);
			}
		}
		for (int i = list.size()-1; i>=0; i--) {
			str = StringUtils.removeCharFromString(str,list.get(i));
		}
		return str;
	}


}
